package com.example.test2018131425.controller;

import com.example.test2018131425.bean.UserBean;
import com.example.test2018131425.service.UserService;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;


@Controller
public class UserController {

    @Resource
    UserService userService;

    @RequestMapping("/users")
    public String index(Model model, @RequestParam(defaultValue = "2") Integer pageNum, @RequestParam(defaultValue = "3") Integer pageSize){

        PageInfo<UserBean> pageInfo = userService.selectUser4Page(pageNum,pageSize);

        model.addAttribute("pageInfo",pageInfo);
        model.addAttribute("userList",pageInfo.getList());
        return "users";
    }
}
